Error when trying to delete object

Hello all,

I have a import script that parses a text file and places the text into a range of objects under a certain top level object. There is a situation that I may run into where I may 5 objects in a text file and 7 objects already in the document. To counteract this I am trying to delete all the objects in the top level object at the beginning of my import. However, I am getting this error:

"cannot delete Object: no access to source object"
This is the part of the code that I'm using to delete the objects:

{
temp = top."Object Heading"

if(temp == "My Heading")
{
for del in top do
{
delete del
}
}
}

I'm not all that familiar with DXL so I would any appreciate any help or advice on the matter.

Does anyone know how to fix this error? or perhaps another method to achieve the same result?

Thanks in advance for any help!

-Kory
SystemAdmin - Thu Feb 14 11:16:27 EST 2013

Re: Error when trying to delete object
SystemAdmin - Thu Feb 14 11:19:48 EST 2013

My apologies, here is a cleaner look at some of my code.

for top in all current Module do
{

temp = top."Object Heading"

if(temp == "Test Software Procedure")
{

for del in top do
{

del."Object Text" = ""
delete del

}

}

}

Re: Error when trying to delete object
llandale - Thu Feb 14 15:08:39 EST 2013

[1] You are modifying a loop variable inside the loop. I'm guessing Doors found an "Object" handle that doesn't really exist.
 

Skip skpDels = create()
int Sequence = 1000000    // try to delete objects bottom up
for del in top do{put(skpDels, Sequence--, del)}
for del in skpDels do
{  softDelete(del)
}
flushDeletions
delete(skpDels)

 


the "for o in o do" loop runs like this:

 

 

del = first Subordinate of top
while (!null del)
{  body of loop
   del = next sibling of del
}



When you delete "del" inside the loop, then it is no longer part of the loop (which only deals with undeleted objects). DOORS then gets lost as to which object is supposed to "follow" an object no longer in the loop.

[2] "delete" I think now means "hardDelete" aka 'purge'

[3] these deletes will fail if the object has incoming links, ??or I think outgoing links??

[4] these deletes will fail if they have subordinate objects to which you have no access or have incoming links.

-Louie